home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 5 / BBS in a Box -Volume V (BBS in a Box) (April 1992).iso / Files / Word / A-Ad / Acius Tech Note 8 < prev    next >
Encoding:
Text File  |  1987-10-16  |  4.3 KB  |  131 lines  |  [TEXT/MSWD]

  1. _______________________________________________________________
  2. 4th Dimension Technical Notes        
  3.  
  4. #8:  4th Dimension External Procedures
  5.  
  6. Written by: Todd Carper    Aug 18, 1987
  7.  
  8. _______________________________________________________________
  9.  
  10. This note discusses the usage of external procedures with 4D
  11. _______________________________________________________________
  12.  
  13. When creating external procedures for 4D it is required that the code be compiled to 
  14. native 68000 code.  Not all compilers will perform this operation.  Following is a 
  15. discussion of tips on creating and installing externals, and directions for using various 
  16. compilers when writing externals.
  17.  
  18. TIPS
  19.  
  20. Do not use global variables in your External Procedures.  Declare all variables to be 
  21. local.
  22.  
  23. Some compilers require that you call the Procedure from your main level in order to have 
  24. that procedure compiled.
  25.  
  26. When passing variables to externals from within 4D, you can pass a local variable to an 
  27. external but you cannot return a value from an external thru a local variable.
  28.  
  29. If you want to install the external directly into your application, instead of thru an EXT file.  
  30. Hold down the Option key while clicking Open in 4D External Mover.  You will then see 
  31. all existing files.  Select the file with the .res extension.  If you install your external into the 
  32. .res file, the external will only be available to that application.
  33.  
  34. It is possible to use ResEdit to install externals, however, it is recommended that for 
  35. reliable installation of externals, only use the 4D External Mover.
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. COMPILERS
  45.  
  46. MPW Pascal
  47. Follow standard procedure for writing, compiling, and installing code.
  48.  
  49. MPW C
  50. Follow standard procedure for writing, compiling, and installing code.
  51. Be sure to pass the address of parameters.  Passed paramters are pushed on the stack 
  52. in reverse order to that of Pascal.
  53.  
  54. LightSpeed C
  55. The following information was contributed by Gary Killingsworth.
  56.  
  57. 1)  All parameters to be passed from 4D to LSC are declared as pointers in main(), and 
  58. main() is declared as a "pascal" function.  Note that you will not be able to run the 
  59. program from LSC using this format!  Example:
  60.  
  61. pascal main(num1, num2)
  62. long    *num1;
  63. short    *num2;
  64.  
  65. 2)  All functions called from main() may be declared as regular C (i.e., non-Pascal) 
  66. functions.
  67.  
  68. 3)  Use Set Project Type to compile the program as a code resource.  Type should be set 
  69. to 'CODE' and ID to '2'.  Unfortunately, there seemd to be no way within LSC to set the 
  70. file attribute to type 'APPL' –– which brings us to step 4.
  71.  
  72. 4)  Using Fedit, choose "File finder attributes" from the Display menu.  Change the type 
  73. from '????' to 'APPL'.  If this step is not included, the 4D External Mover will not display 
  74. the filename.
  75.  
  76. 5)  Per the 4D manual, open your database using the 4D External Mover.  Choose 
  77. transfer, choose SEGMENT 2, offset 0, select your LSC code resource.  Paramters 
  78. should be selected per the manual.
  79.  
  80. 6)  It is important that any resources (such as DITL's and DLOG's) to be used by the 
  81. external function be included alongside the 4DEX, 4BND, and 4DTE resources.  In 
  82. addition to the resources being physically present in the file, the 4BND which bears the 
  83. same I.D. # as your code resource (typically 15000, if only 1 is present) must bundle 
  84. them (as described in the manual).  An important point to remember is that if you delete a 
  85. code resource from your database file using the External Mover, other resources may be 
  86. deleted with it.  For this reason, it might be best to use ResEdit to delete the specific 
  87. 4DEX's and 4BND's which you don't need.
  88.  
  89. At this point, the external procedure should be executable within 4D.  The primary 
  90. reason for using a code resource is that a regular application resource begins with a lot 
  91. of unexecutable code.  4D expects to find the "Link A6" assembly language command at 
  92. the offset which you declare in the External Mover.  In the case of LSC, the code 
  93. resource does not begin directly with this statement, but jumps to it after a few 
  94. housekeeping instructions.
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.     Technical Note #8                        Page   #p of  3
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.